package com.ysd.lis.controller.lab;


import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.lab.LabUnqualifiedGroup;
import com.ysd.lis.entity.lab.LabUnqualifiedReason;
import com.ysd.lis.request.AddAndUpdateUnqualiGroup;
import com.ysd.lis.request.AddAndUpdateUnqualiReason;
import com.ysd.lis.request.DeleteParam;
import com.ysd.lis.service.lab.LabUnqualifiedGroupService;
import com.ysd.lis.service.lab.LabUnqualifiedReasonService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 不合格原因内容表 前端控制器
 * </p>
 *
 * @author Bai
 * @since 2024-02-02
 */
@RestController
@RequestMapping("/lab/unqualified/reason")
public class LabUnqualifiedReasonController extends BaseController {
    @Autowired
    LabUnqualifiedReasonService unqualifiedReasonService;

    //获取不合规信息
    @ApiOperation("获取不合规原因信息（不分页)")
    @GetMapping("/getUnqualifiedReasonList")
    public Result getUnqualifiedReasonList(LabUnqualifiedReason labUnqualifiedReason) {
        return unqualifiedReasonService.getUnqualifiedReasonList(labUnqualifiedReason);
    }

    //新增不合格原因组信息
    @ApiOperation("新增不合格原因信息")
    @PostMapping("/add")
    @LogDetail(requestParam = "add", operationType = OperationType.INSERT, module = "不合格原因管理", content = "通过检验模块，使用不合格原因设置功能新增了：【reasons】不合格原因")
    public Result addGroup(@RequestBody AddAndUpdateUnqualiReason addAndUpdateUnqualiReason) {
        return unqualifiedReasonService.add(addAndUpdateUnqualiReason);
    }
    @ApiOperation("修改不合格原因信息")
    @PostMapping("/update")
    @LogDetail(requestParam = "update", operationType = OperationType.UPDATE, module = "不合格原因管理", content = "通过检验模块，使用不合格原因设置功能修改了：【reasons】不合格原因")
    public Result update(@RequestBody AddAndUpdateUnqualiReason addAndUpdateUnqualiReason) {
        return unqualifiedReasonService.update(addAndUpdateUnqualiReason);
    }

    @ApiOperation("删除不合格原因信息")
    @PostMapping("/dalete")
    @LogDetail(requestParam = "dalete", operationType = OperationType.UPDATE, module = "不合格原因管理", content = "通过检验模块，使用不合格原因设置功能删除了：【names】不合格原因")
    public Result daleteGroup(@RequestBody DeleteParam deleteParam) {
        return unqualifiedReasonService.dalete(deleteParam);
    }

//    获取不合格组与不合格原因列表 
        @ApiOperation("获取不合格组与不合格原因列表（不分页)")
        @GetMapping("/getUnqualifiedList")
        public Result getUnqualifiedList(LabUnqualifiedReason labUnqualifiedReason) {
            return unqualifiedReasonService.getUnqualifiedList(labUnqualifiedReason);
        }

}
